package com.ibeeking.found.cms.api.feign.fallback;

import com.ibeeking.found.cms.api.feign.CmsFeignCpClient;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class CmsFeignCpFallbackFactory implements FallbackFactory<CmsFeignCpClient> {
    @Override
    public CmsFeignCpClient create(Throwable throwable) {
        return new CmsFeignCpClient() {
            @Override
            public ResponseResult<Boolean> removeCacheByIds(Long... ids) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，清除缓存失败", false);
            }
        };
    }
}
